﻿using SimpleUnitity.Cache;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace SimpleUnitity.Cache
{
    public class Queue
    {
        readonly ICache cache;
        public Queue(ICache cache)
        {
            this.cache = cache;
        }

        public void Push(string key, object value)
        {
            cache.Set(key, value);
        }

        public object Pop(string key, object defaultValue = null)
        {
            if (cache.Exists(key))
            {
                object value = cache.Get(key);
                cache.Remove(key);
                return value;
            }
            else
            {
                return defaultValue;
            }
        }

        public bool Exist(string key)
        {
            return cache.Exists(key);
        }

        public void Clear()
        {
            cache.Clear();
        }
    }
}
